<template>
	<view class="main">
		<view class="content">
			<u-form :model="form" ref="uForm">
				<u-form-item prop="name">
					<view class="item">
						<view class="title">首单额度</view>
						<view class="cont">
							<u-input v-model="form.name" type="number" placeholder="请输入USDT数量" />
							<view class="label">USDT</view>
						</view>
					</view>
				</u-form-item>
				<view class="des">按照单位、本金、交易火币计算得出首单买入金额</view>
				<u-form-item prop="name">
					<view class="item">
						<view class="title">做单数量</view>
						<view class="cont">
							<u-input v-model="form.number" type="number" placeholder="请输入USDT数量" />
							<view class="label">单</view>
						</view>
					</view>
				</u-form-item>
				<u-form-item prop="name">
					<view class="item">
						<view class="title">止盈比例</view>
						<view class="cont">
							<u-input v-model="form.name" type="number" placeholder="请输入参数" />
							<view class="label">%</view>
						</view>
					</view>
				</u-form-item>
				<u-form-item prop="name">
					<view class="item">
						<view class="title">止盈回调</view>
						<view class="cont">
							<u-input v-model="form.name" type="number" placeholder="请输入参数" />
							<view class="label">%</view>
						</view>
					</view>
				</u-form-item>
				<u-form-item prop="name">
					<view class="item df" @click="show=true">
						<view class="title">补仓跌幅</view>
						<view class="ico"></view>
						<!-- <view class="cont">
							<u-input v-model="form.name" placeholder="请输入参数" />
							<view class="label">%</view>
						</view> -->
					</view>
				</u-form-item>
				<u-form-item prop="name">
					<view class="item">
						<view class="title">补仓回调</view>
						<view class="cont">
							<u-input v-model="form.name" type="number" placeholder="请输入参数" />
							<view class="label">%</view>
						</view>
					</view>
				</u-form-item>
			</u-form>
			<view class="submit">
				<u-button @click="submit">提交</u-button>
			</view>
			<u-popup v-model="show" mode="bottom" border-radius="14" height="70%">
				<view class="df_cont">
					<view class="item" v-for="(item,index) in form.number" :key="index">
						<view class="cont">
							<view class="label" style="margin-right: 20rpx;text-align: left;">{{index==0?'首次补仓':'第'+(index+1)+'次补仓'}}</view>
							<u-input input-align="right" type="number" v-model="form.numberV[index]" placeholder="请输入参数" />
							<view class="label">%</view>
						</view>
					</view>
					<view class="submit">
						<u-button @click="define">确定</u-button>
					</view>
					
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				form: {
					name: '',
					intro: '',
					number:7,
					numberV:[]
				},
				rules: {
					name: [
						{ 
							required: true, 
							message: '请输入姓名', 
							// 可以单个或者同时写两个触发验证方式 
							trigger: ['change','blur'],
						}
					],
					intro: [
						{
							min: 5, 
							message: '简介不能少于5个字', 
							trigger: 'change'
						}
					]
				}
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		onLoad() {

		},
		onShow() {
			
		},
		methods: {
			// 确定补仓
			define(){
				console.log(this.form.numberV)
			},
			submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						console.log('验证通过');
					} else {
						console.log('验证失败');
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #FFFFFF;
	}
	.main{
		.content{
			padding: 0 28rpx;
			.item{
				width: 100%;
				position: relative;
				margin-top: 34rpx;
				.title{
					font-size: 30rpx;
					font-family: $G-fm;
					font-weight: 600;
					color: #000000;
					line-height: 42rpx;
				}
				.ico{
					width: 0;
					height: 0;
					border: 10rpx solid transparent;
					border-top-color: #000000;
					position: absolute;
					right: 0;
					top:calc(50% - 10rpx)
				}
				.cont{
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					/deep/.u-input{
						width: calc(100% - 120rpx);
						text-align: right;
					}
					.label{
						width: 100rpx;
						font-size: 24rpx;
						font-family: $G-fm;
						font-weight: 600;
						color: #999999;
						line-height: 34rpx;
						text-align: right;
					}
				}
			}
			.des{
				font-size: 24rpx;
				font-family: $G-fm;
				font-weight: 600;
				color: #999999;
				line-height: 34rpx;
			}
			/deep/.u-form-item__message{
				position: absolute;
				right: 0;
				top:44rpx;
			}
			.submit{
				padding: 100rpx 0;
				/deep/button{
					width: 694rpx;
					height: 80rpx;
					background: #2F73FD;
					box-shadow: 0px 4rpx 8rpx 0px #A6C4FF;
					border-radius: 40rpx;
					font-size: 32rpx;
					font-family: $G-fm;
					font-weight: 600;
					color: #FFFFFF;
					line-height: 44rpx;
				}
				/deep/.u-hairline-border:after{
					border: 0;
				}
			}
		}
		.df_cont{
			padding: 30rpx;
			.item{
				border-bottom: 2rpx solid #f5f5f5;		
				.cont{
					justify-content: space-between;
					.u-input{
						width: calc(100% - 220rpx);
					}
					.label{
						width: 120rpx;
						color: #222222;
						
					}
				}
			}
			.submit{
				padding: 20rpx 0;
			}
		}
	}
</style>
